package easysearch
{
	import mx.collections.ArrayCollection;
	import easysearch.classes.App;
	import easysearch.classes.Group;
	import easysearch.classes.Page;
	import easysearch.classes.User;
	import easysearch.classes.Events;
	
	public class ResultCollection
	{

			public var userResults:ArrayCollection;
			public var groupResults:ArrayCollection;
			public var eventResults:ArrayCollection;
			public var pageResults:ArrayCollection;
			public var appResults:ArrayCollection;
			
			// Constructor
			public function ResultCollection()
			{
				userResults = new ArrayCollection();
				groupResults = new ArrayCollection();
				eventResults = new ArrayCollection();
				pageResults = new ArrayCollection();
				appResults = new ArrayCollection();
			}
			
			// Private helper method. Given a type and data,
			// stores the data into the appropriate arraycollection.
			public function addResultToAppropriateCollection(typeOfResult:String, jsonObject:Object){
				switch (typeOfResult) {
					case "user":
						var aUser:User = new User(jsonObject);
						userResults.addItem(aUser);
						break ;
					case "group":
						var aGroup:Group = new Group(jsonObject);
						groupResults.addItem(aGroup);
						break;
					case "event":
						var anEvent:Events = new Events(jsonObject);
						eventResults.addItem(anEvent);
						break ;
					case "application":
						var anApp:App = new App(jsonObject);
						appResults.addItem(anApp);
						break ;
					case "page":
						var aPage:Page = new Page(jsonObject);
						pageResults.addItem(aPage);
						break;
				}
			}
	}
}